﻿#include <QDebug>
#include <QClipboard>
#include <QApplication>

#include "Codecs.h"

const char *examLong = "We're throwing a surprise party for Xiaoming,s birthday. As scheduled, all the classmates in our class will gather at the Students' Centre at 8 pm this Friday evening to celebrate Xiaoming's birthday. We would feel much honored if you could come and enjoy it, which is to finish at 9, lasting an hour. As the party starts, we will light the candles and sing 'Happy Birthday' for him. Then the birthday cake will be presented and cut for all of us to enjoy, following which we'll sing songs and play some small games. What's more, as a surprise, we'll all prepare some secret birthday gifts for him, and it'll be great to see how surprised he will be seeing the gifts. As it's a surprise party, he will know nothing about it beforehand, and we do hope that you could manage to attend it. Looking forward to your coming.";

const char *examShort = "We're throwing a surprise party for Xiaoming,s birthday";

const char *examAesRaw = "LMMC1R20UAV2411162019072220250722001";


#define AES_TEST

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);

    QString rawStr{examLong};

#ifdef BASE64_UNIT_TEST
    // QString b = Codecs::Base64Encode(rawStr);
    // QString bs = Codecs::Base64Decode(b);

    // QString b = Codecs::Base64EncodeBio(rawStr.toLatin1().data());
    // QString bs = Codecs::Base64DecodeBio(b);
    // qDebug() << b;
    // qDebug() << bs;
#endif

#ifdef RSA_TEST
    QByteArray ba = Codecs::RSAEncrypt(rawStr);
    QString bab = Codecs::Base64EncodeBio(ba);

    qDebug() << "Raw Size:" << rawStr.size() << "\nEncrypt String: " << ba << "\nBase64: " << bab << "\nSize: " << ba.size();

    QByteArray ba2 = Codecs::Base64DecodeBio(bab);
    QString bs = Codecs::RSADecrypt(ba2);
    qDebug() << "Decrypt String: " << bs;
#endif

#ifdef AES_TEST
    QByteArray ba = Codecs::AES_ECBEncrypt(examAesRaw);
    QString bs = Codecs::Base64EncodeBio(ba);
    qDebug() << "AES-ECB-128 Enctypt String: " << bs;

    QByteArray ba2 = Codecs::Base64DecodeBio(bs);
    QString bs2 = Codecs::AES_ECBDecrypt(ba2);
    qDebug() << "AES-ECB-128 Decrypt String: " << bs2;

#endif

    return a.exec();
}
